-
Notifications
You must be signed in to change notification settings - Fork 135
feat(gas): add batch listen #3478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 11-17-chore_gas_add_test_for_history_with_holes
Are you sure you want to change the base?
feat(gas): add batch listen #3478
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
Pull Request Review: Batch Listen FeatureThis PR introduces batch signal listening functionality to the workflow engine, allowing workflows to receive multiple signals in a single operation. This is a significant enhancement that can improve throughput and reduce overhead when dealing with multiple signals. SummaryChanges: 1,215 additions, 732 deletions across 16 files Positive AspectsArchitecture & Design
Code Quality
Critical Issues1. Breaking Change: Macro-generated
|
25ece3d to
6ff29f6
Compare
5c9b75f to
0471792
Compare
PR Review: feat(gas): add batch listenSummaryThis PR introduces batch signal listening to the Gasoline workflow engine, allowing workflows to listen for and process multiple signals at once instead of one at a time. This is a significant architectural improvement that can reduce latency and improve throughput for workflows that process multiple signals. Code Quality & Best PracticesStrengths:
Issues & Suggestions:
Potential Bugs
Performance ConsiderationsImprovements:
Concerns:
Security Concerns
Test CoverageMissing:
Recommended Tests: // Test batch listen with multiple signals
#[tokio::test]
async fn test_listen_n_multiple_signals() {
// Send 5 signals, listen for 3, verify we get the oldest 3
}
// Test listen_n with limit larger than available signals
#[tokio::test]
async fn test_listen_n_limit_exceeds_available() {
// Send 2 signals, listen for 5, verify we get 2
}
// Test backward compatibility
#[tokio::test]
async fn test_old_signal_event_conversion() {
// Load workflow with old Signal events, verify they convert to Signals
}
// Test signal ordering across types
#[tokio::test]
async fn test_listen_n_mixed_signal_types() {
// Send signals of type A and B interleaved by time
// Verify they're received in chronological order
}Architecture & DesignPositive:
Questions:
Summary & RecommendationsThis is a well-structured PR that adds valuable batching capabilities to the workflow engine. However, it needs: Must Fix:
Should Fix:
Nice to Have:
The core implementation is solid, but the missing tests and potential edge cases around limits and ordering need to be addressed before merging. Generated by Claude Code |
Code ReviewSummaryThis PR adds batch signal listening capabilities to the Gasoline workflow engine, allowing workflows to receive multiple signals in a single operation instead of one at a time. This is a significant architectural improvement that should improve efficiency when dealing with high-volume signal processing. Architecture Changes✅ Well-designed changes:
Code Quality✅ Strengths:
Potential Issues1. EventType Mismatch in insert::signals_event (packages/gasoline/src/db/kv/keys/history.rs:1645)pub fn signals_event(/* ... */) -> Result<()> {
common(
subspace,
tx,
workflow_id,
location,
EventType::Signal, // ❌ Should be EventType::Signals
version,
create_ts,
)
}This appears to use Recommended fix: EventType::Signals, // Use the new batch signal type2. Missing Validation on Signal CountThe pub struct SignalsEvent {
pub names: Vec<String>,
pub bodies: Vec<Box<serde_json::value::RawValue>>,
}In the database deserialization code (packages/gasoline/src/db/kv/debug.rs:1545), there is a zip operation that could silently drop data if lengths do not match. Consider adding validation: pub struct SignalsEvent {
pub names: Vec<String>,
pub bodies: Vec<Box<serde_json::value::RawValue>>,
}
impl SignalsEvent {
pub fn new(names: Vec<String>, bodies: Vec<Box<serde_json::value::RawValue>>) -> Result<Self> {
ensure\!(names.len() == bodies.len(), "signals names and bodies must have same length");
ensure\!(\!names.is_empty(), "signals event must contain at least one signal");
Ok(Self { names, bodies })
}
}3. Removed CustomListener Without Clear Migration PathThe PR removes the
If any users were using
4. Potential Performance Issue: Sort After Parallel FetchIn .buffer_unordered(1024)
.try_collect::<Vec<_>>()
.await?;
// Sort by ts
signals.sort_by_key(|key| key.create_ts);
// Apply limit
Ok(signals.into_iter().take(limit).collect())The code fetches up to
Recommendation: Consider limiting the total fetch earlier or documenting the tradeoff. Performance Considerations✅ Good:
Security✅ No obvious security concerns
Test Coverage❌ Critical Gap: No Tests for Batch Listening The PR adds significant new functionality but I could not find any tests for:
Recommendation: Add tests covering:
Example test case: #[workflow_test]
async fn test_batch_signal_listen() {
// Publish 5 signals
// ctx.listen_n::<MySignal>(10) should return all 5
// Verify order matches timestamps
}Additional Observations
RecommendationsMust Fix:
Should Consider:
Nice to Have:
VerdictThis is a well-architected feature that makes logical sense for the workflow engine. However, it has a critical bug (wrong EventType) and lacks test coverage. Once these issues are addressed, this will be a solid improvement. Status: Needs Changes 🔴 The EventType bug could cause production issues with history replay, and the lack of tests makes it risky to merge. Please address the critical issues before merging. |
6ff29f6 to
dba469c
Compare
0471792 to
f508120
Compare
PR Review: Add Batch ListenOverviewThis PR introduces batch signal listening capabilities to the Gasoline workflow engine, allowing workflows to receive multiple signals in a single operation. Strengths1. Well-Structured API Changes
2. Comprehensive Database Implementation
3. Good Error Handling
4. Logging and Observability
Concerns1. Breaking API Change Recommendations:
2. Potential Index Corruption 🔴 Recommendations:
3. Empty Vec Semantics
Recommendation: Document when empty vecs are expected vs errors 4. Test Coverage Gaps 🟡
5. Performance 💭 6. Magic Number 🟡 7. Removed EventData::Empty Security & Safety✅ No security concerns ConclusionWell-implemented feature! Main concerns:
Recommendation: Add breaking change docs and batch tests before merging. Overall: Approve with comments 🎉 |
PR Review: feat(gas): add batch listenThis PR introduces batch signal listening to the Gasoline workflow engine, allowing workflows to receive multiple signals in a single operation. This is a significant performance optimization. Architecture ChangesCore API Changes:
Database Layer:
History Management:
Code Quality - Strengths
Areas for Improvement
Potential Bugs
PerformancePositive:
Concerns:
SecurityNo significant issues. Proper conflict ranges prevent races, signal ack prevents double-delivery. Test CoverageMissing: No test files in PR. Critical tests needed:
Best PracticesFollows CLAUDE.md conventions well (structured logging, lowercase messages, anyhow::Result, proper timestamps). Minor: Some functions exceed reasonable length (180 lines). Consider extracting helpers. Final RecommendationAPPROVE with minor recommendations Well-architected change with meaningful performance improvements. Code quality is high and follows conventions. Before merging:
Nice work! The parallel signal fetching is particularly well done. |
dba469c to
2a53bcf
Compare
f508120 to
512771d
Compare
PR Review: feat(gas): add batch listenI've completed a thorough review of this PR. Overall, this is a well-architected change that adds batch signal listening to the workflow engine. StrengthsArchitecture & Design:
Implementation Quality:
Database Layer:
Issues & Concerns1. Missing signal_ids field in SignalsEvent (history/event.rs:211-214) The SignalsEvent struct only has names and bodies, but the debug version includes signal_ids. This inconsistency could cause issues when replaying history or debugging workflows. Recommendation: Add signal_ids: Vec to the main SignalsEvent struct for consistency. 2. Potential ordering issue in listen_n_until When signals are received during a timeout, they may not maintain consistent ordering across different code paths. Recommendation: Document whether signal order within a batch is guaranteed. 3. Empty Vec handling could be clearer (ctx/workflow.rs:706-708) If listen_n returns an empty vec due to a bug, this panics with a generic error rather than a workflow error. Recommendation: Use WorkflowError instead of generic context for better error handling. 4. Missing validation in pull_next_signals The limit parameter is used directly without validation. If limit is 0, this could cause unexpected behavior. Recommendation: Add validation at the API boundary to ensure limit > 0. 5. Deprecated Signal event type The old Signal event type is marked deprecated but may not be handled in all match statements. Recommendation: Verify all match statements handle the deprecated type appropriately. Performance ConsiderationsPositive:
Potential concerns:
Recommendation: Consider adding configuration for max batch size or document recommended limits. SecurityNo security concerns identified. The implementation properly validates versions during history replay and uses appropriate transaction isolation levels. Test CoverageNeeds attention:
Recommendation: Add comprehensive tests for the new batch functionality. SummaryThis is a well-implemented feature that significantly improves the workflow engine's signal handling capabilities. The main concerns are:
Overall Assessment: Approve with recommendations to address the issues above, particularly adding the signal_ids field and test coverage. Great work on maintaining code quality and following the project's conventions! |
PR Review: feat(gas): add batch listenSummaryThis PR adds batch listening functionality to the Gasoline workflow engine, allowing workflows to listen for and process multiple signals at once. This is a significant architectural improvement that reduces database transactions and improves throughput. Code Quality ✅
Potential Issues
|

No description provided.